#!/bin/bash

function info() {
echo Usage: `basename $0` 'list'
exit 1
}

while getopts  ":p:f:" opt; do
	case  $opt  in
		p) out_prefix=$OPTARG;;
		f) suffix=$OPTARG;;
		*) info;;
	esac
done
shift $(($OPTIND - 1))


if [ $# -lt 1 ]; then info; fi

. $var

# cd $data/adm
# for out_prefix in 1.5 1.10 1.20; do
    # out_prefix=${out_prefix}.filt
    # for k in `seq 2 12`; do
        # echo $out_prefix.$k.q.sort
        # q_bar1.py -ptes.$out_prefix.$k $out_prefix.$k.q.sort sample.species2
    # done

# done


out_prefix=$out_prefix.filt_chain
cut -f1 $out_prefix.ped -d' ' > $out_prefix.sample.list

echo admixture
for k in `seq 3 9`; do
    admixture --cv -j$num_thread $out_prefix.bed $k > $out_prefix.$k.log
    sed -i 's/ /\t/g' $out_prefix.$k.Q
    paste $out_prefix.sample.list $out_prefix.$k.Q > $out_prefix.$k.q
    

done

. $cmd_done
